package com.example.fundappcation.base;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import io.reactivex.rxjava3.disposables.CompositeDisposable;
import io.reactivex.rxjava3.disposables.Disposable;

public abstract class BaseActivity extends AppCompatActivity {
    private CompositeDisposable compositeDisposable;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(initView());

        init();
        initLoad();
        initData();
    }

    //添加View
    protected abstract View initView();

    //绑定布局，初始化布局属性
    protected abstract void init();

    //加载进度条
    protected abstract void initLoad();

    //加载数据
    protected abstract void initData();

    //收集Rxjava
    public void addSubject(Disposable disposable) {
        compositeDisposable.add(disposable);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        compositeDisposable.dispose();
    }
}
